import {Describer, MONTH_MAP_ARRAY, NUMBER_MAP_CHINESE,} from "./base";

export class MonthPartDescriber extends Describer {

  // *
  starSegment(exp: '*') {
    return '每月'
  }

  // */3
  starSlashNumberSegment(exp: string) {
    const interval = exp.replace(`*/`, '')
    return `每${interval}个月`
  }

  // 1-9/3
  spanSlashNumberSegment(exp: string) {
    const [_, start, end, interval] = exp.match(/^(\d+)-(\d+)\/(\d+)$/)
    return `${NUMBER_MAP_CHINESE[start]}到${MONTH_MAP_ARRAY[end]}中的每${interval}个月`
  }

  //1-9
  spanSegment(exp: string) {
    const [_, start, end] = exp.match(/^(\d+)-(\d+)$/)
    return `${NUMBER_MAP_CHINESE[start]}到${MONTH_MAP_ARRAY[end]}`
  }

  // 3
  singleNumberSegment(exp: string) {
    return MONTH_MAP_ARRAY[exp] || exp
  }

}
